var addHospitalDialog;//添加医院弹框
var addKeshiDialog;//添加科室弹框
var addJibingDialog;//添加疾病弹框
var addDocDialog;//添加医生弹框

function yiyuanInit()
{
	 BUI.use(['bui/overlay','bui/form'],function(Overlay,Form){
	      	var form = new Form.HForm({
	        	srcNode : '#form'
  	 }).render();
	      	
	      //添加管理员
		 addHospitalDialog = new Overlay.Dialog({
	           title:'添加管理员',
	           width:500,
	           height:320,
	           //配置DOM容器的编号
	           contentId:'admin_content',
	           cancel:function(){
	   	      	clearDocDialog();
	   	     },
	           success:function () {
	           	saveOrUpdateKe();
	             }
	   	     });
		 //添加医院
		 addHospitalDialog = new Overlay.Dialog({
	           title:'添加医院',
	           width:500,
	           height:320,
	           //配置DOM容器的编号
	           contentId:'hospital_content',
	           cancel:function(){
	   	      	clearDocDialog();
	   	     },
	           success:function () {
	           	saveOrUpdateKe();
	             }
	   	     });
   	 
		 //添加科室
		 addKeshiDialog = new Overlay.Dialog({
	        title:'添加科室',
	        width:500,
	        height:320,
	        //配置DOM容器的编号
	        contentId:'keshi_content',
	        cancel:function(){
		      	clearDocDialog();
		     },
	        success:function () {
	        	saveOrUpdateKe();
	          }
		 	});
		 
		//添加疾病
		 addJibingDialog = new Overlay.Dialog({
	        title:'添加疾病',
	        width:500,
	        height:320,
	        //配置DOM容器的编号
	        contentId:'jibing_content',
	        cancel:function(){
		      	clearDocDialog();
		     },
	        success:function () {
	        	saveOrUpdateKe();
	          }
		 	});
		 
		//添加医生
		 addDocDialog = new Overlay.Dialog({
	        title:'添加医生',
	        width:500,
	        height:320,
	        //配置DOM容器的编号
	        contentId:'doc_content',
	        cancel:function(){
		      	clearDocDialog();
		     },
	        success:function () {
	        	saveOrUpdateKe();
	          }
		 	});
		 
	 });
	 
	 $("#addAdmintal").bind("click",function(){
	   	   clearDocDialog();
	   	   addHospitalDialog.set("title","添加医院");
	   	   $("#admin_type").val("1");
	   	   addHospitalDialog.show();
	  });
	 
	 $("#addHospital").bind("click",function(){
	   	   clearDocDialog();
	   	   addHospitalDialog.set("title","添加医院");
	   	   $("#hospital_type").val("1");
	   	   addHospitalDialog.show();
	  });
	 
	  $("#addKeshi").bind("click",function(){
		   clearDocDialog();
		   addKeshiDialog.set("title","添加科室");
		   $("#keshi_type").val("1");
		   addKeshiDialog.show();
	  });
	  
	  $("#addJibing").bind("click",function(){
		   clearDocDialog();
		   addJibingDialog.set("title","添加疾病");
		   $("#jibing_type").val("1");
		   addJibingDialog.show();
	  });
	  
	  $("#addDoc").bind("click",function(){
		   clearDocDialog();
		   addDocDialog.set("title","添加医生");
		   $("#doc_type").val("1");
		   addDocDialog.show();
	  });
  
}


/**
 * 修改科室
 */
function editKeshi(id)
{
	var url = projectName + "manage/" + new Date().getTime(); 
	$.ajax({
		url: url,
		async:false,
		data:{
			
		},
		success:function(data)
		{
			addKeshiDialog.set("title","编辑科室");
			addKeshiDialog.show();
		},
		error:function(result){
			alert("editKeishi is ERROR !");
		}
	});
	
}

/**
 * 保存修改管理员
 */
function saveUpdateAdmin()
{
	//type=1为保存   2为修改
	var type = $("#admin_type").val();
	var url = projectName + "manage/.do?date=" + new Date().getTime();
	$.ajax({
		url: url,
		type:"post",
		async:false,
		data:$('#addform').serialize(),
		success:function(data)
		{
		},
		error:function(result){
			alert("saveUpdateAdmin is ERROR !");
		}
	});
}